'''
 yaml文件的相关操作
'''
import os
import yaml

# 写入到yaml文件中
def write_yaml(filename, data):
    with open(os.getcwd()+'/data/'+filename,mode='a+',encoding='utf-8') as f:
        yaml.dump(data, stream=f)

# 从yaml文件中获取对应的数据
def read_yaml(filename,key):
    with open(os.getcwd()+'/data/'+filename,mode='r',encoding='utf-8') as f:
        data = yaml.load(f, Loader=yaml.FullLoader)
        return data[key]

# 清空yaml文件
def clear_yaml(filename):
    with open(os.getcwd()+'/data/'+filename,mode='w',encoding='utf-8') as f:
        f.truncate()